package cn.itcast.account.web;

import cn.itcast.account.service.AccountService;
import cn.itcast.account.service.TCCAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 虎哥
 */
@RestController
@RequestMapping("account")
public class AccountController {

   // @Autowired
   // private AccountService accountService;

    @Autowired
    private TCCAccountService tccAccountService;







    /**
     * 根据用户ID去扣除余额
     * @param userId
     * @param money
     * @return
     */
    @PutMapping("/{userId}/{money}")
    public ResponseEntity<Void> deduct(@PathVariable("userId") String userId, @PathVariable("money") Integer money){
        //accountService.deduct(userId, money);
        tccAccountService.tryTcc(userId,money);
        return ResponseEntity.noContent().build();
    }
}
